<access_control grant="admin, dev"> 
    <div class="backup_container">
        <center><message id="backupCss" /></center>
        <br/>
        <!-- CSS BACKUP -->
        <div class="backup_div">
            <?php
            $backupList = Erra_Core_File::spl_scanRecursiveDir(DOCUMENT_ROOT . '/backup/css');
            $res = '<table class="css_backup">';
            $res .= '<tr><td>';
            $saveCss = Std_ActionObject::getObject('save_css', 'CREATE')->setDescription(__('Backup `/public/style` directory'));
            $saveCss->hidden_field->append('<center><img src="WEBROOT/__erra/images/cmsimages/css-icon.png" /></center>');
            $saveCss->renderEngine = 'custom';
            $res .= $saveCss->_form('AdminAction/saveCssBackup');
            $res .= '</tr></td>';
            foreach ($backupList as $item) {
                $res .= '<tr><td>';
                $res .= '<img src="WEBROOT/__erra/images/cmsimages/download-icon.png" /> ';
                $res .= basename($item);
                $res .= '<br/>';
                // Restore CSS item
                $res .= '<div class="backup_action">';
                $objectId = str_replace(array('-', '.'), '_', basename($item));
                $restoreCss = Std_ActionObject::getObject('restore' . $objectId, 'CREATE', null, basename($item))->setDescription('')->setActionName(__('Restore'));
                $restoreCss->renderEngine = 'none';
                $res .= $restoreCss->_form('AdminAction/restoreCssBackup');
                $res .= '</div>';
                $res .= '<div class="backup_action">';
                // Delete CSS item
                $restoreCss = Std_ActionObject::getObject('delete' . $objectId, 'CREATE', null, basename($item))->setDescription('')->setActionName(__('Delete'));
                $restoreCss->renderEngine = 'none';
                $res .= $restoreCss->_form('AdminAction/deleteCssBackup');
                $res .= '</div>';
                $res .= '<div style="clear:both"></div>';
                $res .= '</td></tr>';
            }
            $res .= '</table>';
            echo $res;
            ?>
        </div>
        <!-- SITE RESOURCES BACKUP -->
        <div class="backup_div">
            <?php
            $backupList = Erra_Core_File::spl_scanRecursiveDir(DOCUMENT_ROOT . '/backup/site');
            $res = '<table class="css_backup">';
            $res .= '<tr><td>';
            $saveSite = Std_ActionObject::getObject('save_site', 'CREATE')->setDescription(__('Backup site `/public` directory'));
            $saveSite->hidden_field->append('<center><img src="WEBROOT/__erra/images/cmsimages/backup-icon.png" /></center>');
            $saveSite->renderEngine = 'custom';
            $res .= $saveSite->_form('AdminAction/saveSiteBackup');
            $res .= '</tr></td>';
            foreach ($backupList as $item) {
                $res .= '<tr><td>';
                $res .= '<img src="WEBROOT/__erra/images/cmsimages/download-icon.png" /> ';
                $res .= basename($item);
                $res .= '<br/>';
                // Delete CSS item
                $res .= '<div class="backup_action">';
                $restoreCss = Std_ActionObject::getObject('delete' . $objectId, 'CREATE', null, basename($item))->setDescription('')->setActionName(__('Delete'));
                $restoreCss->renderEngine = 'none';
                $res .= $restoreCss->_form('AdminAction/deleteSiteBackup');
                $res .= '</div>';
                $res .= '</td></tr>';
            }
            $res .= '</table>';
            echo $res;
            ?>
        </div>
        <!-- CSS BACKUP -->
        <div class="backup_div">
            <?php
            $backupList = Erra_Core_File::spl_scanRecursiveDir(DOCUMENT_ROOT . '/backup/sql');
            $res = '<table class="css_backup">';
            $res .= '<tr><td>';
            $saveCss = Std_ActionObject::getObject('save_sql', 'CREATE')->setDescription(__('Create SQL database dump'));
            $saveCss->hidden_field->append('<center><img src="WEBROOT/__erra/images/cmsimages/mysql-icon.png" /></center>');
            $saveCss->renderEngine = 'custom';
            $res .= $saveCss->_form('AdminAction/saveSqlBackup');
            $res .= '</tr></td>';
            foreach ($backupList as $item) {
                $res .= '<tr><td>';
                $res .= '<img src="WEBROOT/__erra/images/cmsimages/download-icon.png" /> ';
                $res .= basename($item);
                $res .= '<br/>';
                // Restore SQL database
                $res .= '<div class="backup_action">';
                $objectId = str_replace(array('-', '.'), '_', basename($item));
                $restoreCss = Std_ActionObject::getObject('restore' . $objectId, 'CREATE', null, basename($item))->setDescription('')->setActionName(__('Restore'));
                $restoreCss->renderEngine = 'none';
                $res .= $restoreCss->_form('AdminAction/restoreSqlBackup');
                $res .= '</div>';
                // Delete SQL backup
                $res .= '<div class="backup_action">';
                $restoreCss = Std_ActionObject::getObject('delete' . $objectId, 'CREATE', null, basename($item))->setDescription('')->setActionName(__('Delete'));
                $restoreCss->renderEngine = 'none';
                $res .= $restoreCss->_form('AdminAction/deleteSqlBackup');
                $res .= '</div>';
                $res .= '<div style="clear:both"></div>';
                $res .= '</td></tr>';
            }
            $res .= '</table>';
            echo $res;
            ?>
        </div>
        <div style="clear:both"></div>
    </div>
</access_control>